import java.util.*;
public class dianying {
		public static void main(String[]args) {
	   while(true) {
		   Station station1=new  Station ("窗口1");
		   Station station2=new  Station("窗口2");
		   System.out.println("购票按1，退票按2");
		   Scanner reader=new Scanner(System.in);
		  int a=reader.nextInt();
		  switch(a) {
		  case 1:station1.sell();break;
		  case 2:station2.back();return;
		  }
	   }
		}
	}
	  class Station extends Thread{
		  public static int ticket=100;
		  public Station(String name) {
			  super(name);
		  }
		  public void sell() {
			  System.out.println("购买票数为：");
			  Scanner reader=new Scanner(System.in);
			  int a=reader.nextInt();
			  System.out.println("已购买"+a+"张票");
			  ticket=ticket-a;
			  System.out.println("还有"+ticket+"张票");
			  
		  }
		  public void back() {
			  System.out.println("输入退票数目：");
			  Scanner reader=new Scanner (System.in);
			  int a=reader.nextInt();
			  System.out.println("退票成功。");
			  ticket=ticket+a;
			  System.out.println("还有"+ticket+"张票");
		  }
	  }

